package com.weasel.im.common.channel;

import com.google.common.collect.Maps;
import io.netty.channel.Channel;

import java.util.Map;

/**
 * Created by Dylan on 2015/11/30.
 */
public class IMChannelGroup {

    private final static Map<String,Channel> channelGroup = Maps.newConcurrentMap();

    /**
     * @param channelName
     * @param channel
     * @return
     */
    public IMChannelGroup register(String channelName,Channel channel){

        channelGroup.put(channelName,channel);
        return this;
    }

    /**
     *
     * @param channelName
     * @return
     */
    public IMChannelGroup unRegister(String channelName){

        channelGroup.remove(channelName);
        return this;
    }

    /**
     * @param channelName
     * @return
     */
    public Channel getChannel(String channelName){

        return channelGroup.get(channelName);
    }
}
